﻿<UserControl x:Class="YourLastOptionsDialog.Controls.ValidatingPasswordBox"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">
    
    <UserControl.Resources>
        <Style x:Key="CustomPasswordBoxStyle" TargetType="PasswordBox">
            <Setter Property="FontFamily"
                    Value="{StaticResource PhoneFontFamilyNormal}" />
            <Setter Property="FontSize"
                    Value="{StaticResource PhoneFontSizeMediumLarge}" />
            <Setter Property="Background"
                    Value="{StaticResource PhoneTextBoxBrush}" />
            <Setter Property="Foreground"
                    Value="{StaticResource PhoneTextBoxForegroundBrush}" />
            <Setter Property="BorderBrush"
                    Value="{StaticResource PhoneTextBoxBrush}" />
            <Setter Property="SelectionBackground"
                    Value="{StaticResource PhoneAccentBrush}" />
            <Setter Property="SelectionForeground"
                    Value="{StaticResource PhoneTextBoxSelectionForegroundBrush}" />
            <Setter Property="BorderThickness"
                    Value="{StaticResource PhoneBorderThickness}" />
            <Setter Property="Padding"
                    Value="2" />
        </Style>
    </UserControl.Resources>
    
    <Grid x:Name="LayoutRoot">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <PasswordBox x:Name="PasswordBox"
                     Style="{StaticResource CustomPasswordBoxStyle}"
                     LostFocus="PasswordBox_OnLostFocus"/>
        <TextBlock x:Name="ValidationMessageTextBlock"
                   Grid.Row="1"
                   Foreground="Red"
                   Visibility="Collapsed"
                   TextWrapping="Wrap"
                   Margin="12,0,12,12"
                   HorizontalAlignment="Left"
                   Style="{StaticResource PhoneTextSmallStyle}" />
    </Grid>
</UserControl>